package br.ufpe.cin.plebeia.webapp.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import br.ufpe.cin.plebeia.model.Abelha;
import br.ufpe.cin.plebeia.persistence.hibernateDao.HibernateAbelhaDao;
import br.ufpe.cin.plebeia.webapp.form.ListActionForm;
import br.ufpe.cin.plebeia.webapp.infra.PathDispatchAction;

public class AbelhaAction extends PathDispatchAction {
	private static final String JSP = "jsp";

	private HibernateAbelhaDao dao = new HibernateAbelhaDao();

	public ActionForward listarAbelha(ActionMapping actionMapping,
			ActionForm actionForm, HttpServletRequest httpServletRequest,
			HttpServletResponse httpServletResponse) throws Exception {
		List<Abelha> abelhas = dao.retrieveAll();
		ListActionForm form = (ListActionForm) actionForm;
		form.setList(abelhas);
		return actionMapping.findForward(JSP);
	}
}
